import com.wanwan.ReptileApplication;
import lombok.extern.slf4j.Slf4j;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import utils.ConnectHttps;

import java.io.IOException;

@RunWith(SpringRunner.class)
@SpringBootTest
@ContextConfiguration(classes = ReptileApplication.class)
@Slf4j
public class test {

    @Test
    public void test1() throws IOException {
        ConnectHttps.trustEveryone();
        Connection connect =  Jsoup.connect("https://www.unjs.com/gongzuozongjie/2210704.html");
        connect.header("Sec-Fetch-User","?1");
        connect.header("Upgrade-Insecure-Requests","1");
        connect.header("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36");
        Document document = connect.get();
        Element element = document.select("div.content").first();
        String content = element.text();
        System.out.println(content);
    }

    @Test
    public void test2() throws IOException {
        Document document = Jsoup.connect("http://www.0551dqwx.com/25102.html").get();
        Element element = document.select(".PostContent").first();
        System.out.println(element.text());
    }
}
